package com.demo.controller;

import com.demo.service.IDemoService;
import com.spring.framework.annotation.MyAutowired;
import com.spring.framework.annotation.MyController;
import com.spring.framework.annotation.MyRequestMapping;
import com.spring.framework.annotation.MyRequestParam;
import com.spring.framework.webmvc.servlet.MyModelAndView;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ππ
 * @date 2020-11-17 15:44
 * @desc
 */
@MyController
public class PageController {
    @MyAutowired
    private IDemoService demoService;

    @MyRequestMapping(value = "/first.html")
    public MyModelAndView query(@MyRequestParam("name")String name){
        String result = demoService.queryByName(name);
        Map<String,Object> model = new HashMap<String,Object>();
        model.put("name", name);
        model.put("data", result);
        model.put("token", "123456");
        model.put("time",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        return new MyModelAndView("first",model);
    }
}
